
import {
	defineStore
} from 'pinia'

import {
	ref
} from 'vue'
export const userStore = defineStore("user", () => {
	let userInfo = ref({})
	let token=ref(0)
	let isLogin = ref(false)
	let currentPos=ref({
		latitude:34.342,
		longitude:108.9397
	})
	let hasPos = ref(false)
	function addUserInfo(id, username, phone) {		
   //自行添加内容
	}
	// 清除用户登录状态
	function clearUserInfo() { 
//自行添加内容
	}
	function setPos(lat,lon){
		currentPos.value.latitude=lat
		currentPos.value.longitude=lon
		hasPos.value=true
	}
 function addUserInfo(id,username,email,mobile,token)
   {
     this.userInfo.id=id
     this.userInfo.username=username;
     this.userInfo.email=email;
     this.userInfo.mobile=mobile;
     this.token=token            
     this.isLogin=true
 
   }
   function clearUserInfo()
   {
     	this.userInfo = {}
 			this.isLogin = false
 			this.token = ""
   }
	return {
		userInfo,
		isLogin, 
		addUserInfo,
		clearUserInfo, 
		currentPos,
		setPos,
		hasPos,token
	}
})